package com.bidepan.factoryBean;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
    @Test
    public void test(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean-factorybean.xml");
        User user = context.getBean("user", User.class);
        User user2 = context.getBean("user", User.class);
        System.out.println(user.toString());
        System.out.println(user2.toString());
        System.out.println(user == user2); // true: FactoryBean返回的Bean是单例的
        user2.setName("mike");
        System.out.println(user.toString());
        System.out.println(user2.toString());
    }
}
